package com.tvunetworks.center.user.mapper;


import com.tvunetworks.center.user.model.*;
import com.tvunetworks.center.user.model.param.SearchBookmarkDeviceParam;
import com.tvunetworks.center.user.model.vo.AlreadyShareSonListVo;
import com.tvunetworks.center.user.model.vo.PeerIdWithBookmarkId;
import com.tvunetworks.center.user.model.vo.SearchUserDeviceVo;
import org.apache.ibatis.annotations.Param;
import tk.mybatis.mapper.additional.insert.InsertListMapper;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

/**
 * @author lebronchen
 */
public interface BookmarkDeviceMapper extends Mapper<BookmarkDevice>,InsertListMapper<BookmarkDevice> {

    /**
     *  查询用户在指定书签下的peerIds
     * @param bookmarkIds bookmarkIds
     * @param condition condition
     * @return List
     */
    List<String> listBookmarkPeerIds(@Param("bookmarkIds") List<String> bookmarkIds, @Param("condition") String condition);

    /**
     *  查询用户所有书签下的peerIds
     * @param userId userId
     * @param condition condition
     * @return List
     */
    List<String> listUserInBookmarkPeerIds(@Param("userId") String userId,@Param("condition") String condition);

    /**
     *
     * @param userId userId
     * @param peerIds peerIds
     * @return List
     */
    List<BookmarkNameDevice> listUserDeviceBookmarks(@Param("userId") String userId, @Param("peerIds") List<String> peerIds);

    /**
     *
     * @param userIds userIds
     * @return List
     */
    List<String> listUserBookmarkDevice(@Param("userIds") List<String> userIds);

    /**
     *
     * @param ids ids
     */
    void removeUserBookmarkDevice(@Param("ids") List<String> ids);

    /**
     *
     * @return List
     */
    List<PeerIdWithBookmarkId> listPeerIdBookmarkId();

    /**
     *
     * @param param param
     * @return List
     */
    List<SearchUserDeviceVo> listUserAllPeerIds(SearchBookmarkDeviceParam param);

    /**
     *
     * @param param param
     * @return List
     */
    List<SearchUserDeviceVo> listBindedDevice(SearchBookmarkDeviceParam param);

    /**
     *
     * @param bookmarkIds bookmarkIds
     */
    void deleteBookmarkDevice(@Param("bookmarkIds") List<String> bookmarkIds);
    


    /**
     //查询绑定的token device的数据
     * @param peerIdOrName peerIdOrName
     * @param userId userId
     * @param bookmarkId bookmarkId
     * @return List
     * @throws Exception 编译异常
     */
    List<SearchUserDeviceVo> listBindTokenDevice(@Param("peerIdOrName") String peerIdOrName,@Param("userId") String userId,@Param("bookmarkId") String bookmarkId) throws Exception;

    /**
     *
     * @param userId userId
     * @return List
     */
    List<String> getBindTRPeerIdList(String userId);

    /**
     *
     * @param bookmarkId bookmarkId
     * @param userId userId
     * @return String
     */
    String getAllChildBookmarkIds(@Param("bookmarkId")String bookmarkId,@Param("userId")String userId);

    /**
     *
     * @param userId userId
     * @return List
     */
    List<String> getAllChildBookmarkId(@Param("userId")String userId);

    /**
     *
     * @param userId userId
     * @param bookmarkId bookmarkId
     * @param childIds childIds
     * @return List
     */
    List<UserBookmark> getAllChildBookmarkList(@Param("userId") String userId, @Param("bookmarkId") String bookmarkId, @Param("childIds") List<String> childIds);

    /**
     *
     * @param userId userId
     * @param bookmarkId bookmarkId
     * @param childIds childIds
     * @param type type
     * @return List
     */
    List<BookmarkDevice> getAllChildBookmarkDeviceList(@Param("userId") String userId, @Param("bookmarkId")String bookmarkId,  @Param("childIds") List<String> childIds,@Param("type") String type);

    /**
     *
     * @param userId userId
     * @param bookmarkId bookmarkId
     * @param childIds childIds
     * @param type type
     * @return List
     */
    List<String> getAllChildDevicePeerIdList(@Param("userId") String userId, @Param("bookmarkId") String bookmarkId, @Param("childIds") List<String> childIds, @Param("type") String type);

    /**
     *
     * @param oldPeerId oldPeerId
     * @param newPeerId newPeerId
     * @return List
     */
    List<String> listBoomarkIdsInPeerId1NotInPeerId2(@Param("oldPeerId") String oldPeerId, @Param("newPeerId") String newPeerId);

    /**
     *
     * @param userId userId
     * @param bookmarkId bookmarkId
     * @return List
     */
    List<SearchUserDeviceVo> listUserBookmarkAllDevice(@Param("userId") String userId, @Param("bookmarkId") String bookmarkId);

    /**
     *
     * @param userId userId
     * @param peerId peerId
     * @return List
     */
    List<BookmarkDevice> listUserDeviceBookmarksByPeerId(@Param("userId") String userId, @Param("peerId") String peerId);

    /**
     * 或者指定用户下指定bookmarkId集合对应得所有Token配对得所有anywhere
     * @param userId userId
     * @param bookmarkIds bookmarkIds
     * @param condition condition
     * @return List
     */
    List<String> listBindedDeviceListForTokenByBookmarkIds(@Param("userId") String userId, @Param("bookmarkIds") List<String> bookmarkIds,
                                                           @Param("condition") String condition);


    /**
     * 分享父账号下bookmark内容给子账号
     * @param bookMarkShareList  bookMarkShareList
     */
     void saveBookMarkShareBatch(List<BookMarkShare> bookMarkShareList) ;



    /**
     //移除分享的bookMark
     * @param subUserId subUserId
     * @param parentUserId parentUserId
     * @param updateTime updateTime
     */
     void deleteBookMarkShare(@Param("subUserId") String subUserId,@Param("parentUserId") String parentUserId,@Param("updateTime") Long updateTime) ;





    /**
     //查询父账号已经分享过的子账号
     * @param userId userId
     * @return List
     */
    List<AlreadyShareSonListVo>  getAlreadyShareSonList(@Param("userId") String userId) ;

}
